import {
	ajax
} from "../../utils/request.js";

// 获取保单列表函数
const baoDanList = (params = {}) => {
  return ajax('/api/dixiu/getmaintainerworkorder', "POST", params);
}


// 获取保单列表函数
const jieDanList = (params = {}) => {
  return ajax('/api/dixiu/acceptorder', "POST", params);
}

// 封装的获取保单列表函数
function getBaoDanList() {
  return new Promise((resolve, reject) => {
    baoDanList().then(res => {
      // 打印完整的响应数据
      console.log('获取保单列表成功:', res);
      resolve(res);
    })
    .catch(err => {
      console.error('获取保单数据失败:', err);
      reject(err);
    });
  });
}

// 封装接单函数（接收工单ID参数）
function getjieDanList(orderId) {
  return new Promise((resolve, reject) => {
	  console.log(orderId+"工单ID")
    
    jieDanList({ workorderorderId: orderId }).then(res => {
      console.log('接单成功:', res);
      resolve(res);
    }).catch(err => {
      console.error('接单失败:', err);
      reject(err);
    });
  });
}

export {
	getBaoDanList,
	getjieDanList
}